package org.microsites.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.microsites.domain.dao.DatabaseDAO;
import org.microsites.domain.model.Database;
import org.microsites.domain.model.Entity;
import org.microsites.service.DatabaseService;
import org.microsites.service.ServerService;

public class DatabaseServiceImpl extends GenericServiceImpl<Database> implements DatabaseService {

	private DatabaseDAO databaseDAO;
	private ServerService serverService;
	
	@Override
	public DatabaseDAO getDAO() {
		return databaseDAO;
	}

	public void setDatabaseDAO(DatabaseDAO databaseDAO) {
		this.databaseDAO = databaseDAO;
	}

    @Override
    public List<Entity> loadPath(Long id) {
        if (id == null) return new ArrayList<Entity>();

        Database d = this.load(id);
        if (d == null) return new ArrayList<Entity>();
        
        List<Entity> list = serverService.loadPath(d.getServer());
        list.add(d);

        return list;
    }

    public ServerService getServerService() {
        return serverService;
    }

    public void setServerService(ServerService serverService) {
        this.serverService = serverService;
    }
}
